package xjtu.sad.zbsj.task.annotater.labelTask;

import java.util.ArrayList;
import java.util.List;

public class MarkDetail {
    private Integer detailId;// 该条标注id
    private Integer markId;// 用户领取样本id
    private Integer attrNameId;// 属性名Id
    private String attrName;// 属性名
    private List<String> attrValueList;// 用户标注的属性值,对于select来说是id,对于input来说是文本
    private String attrValue;// 该条属性值

    public MarkDetail() {
        attrValueList = new ArrayList<>();
    }

    public MarkDetail(MarkDetail markDetail, String attrValue) {
        this.detailId = markDetail.detailId;
        this.markId = markDetail.markId;
        this.attrNameId = markDetail.attrNameId;
        this.attrName = markDetail.attrName;
        this.attrValue = attrValue;
        attrValueList = new ArrayList<>();
    }

    public String getAttrValue() {
        return attrValue;
    }

    public void setAttrValue(String attrValue) {
        this.attrValue = attrValue;
    }

    public Integer getDetailId() {
        return detailId;
    }

    public void setDetailId(Integer detailId) {
        this.detailId = detailId;
    }

    public Integer getMarkId() {
        return markId;
    }

    public void setMarkId(Integer markId) {
        this.markId = markId;
    }

    public Integer getAttrNameId() {
        return attrNameId;
    }

    public void setAttrNameId(Integer attrNameId) {
        this.attrNameId = attrNameId;
    }

    public String getAttrName() {
        return attrName;
    }

    public void setAttrName(String attrName) {
        this.attrName = attrName;
    }

    public List<String> getAttrValueList() {
        return attrValueList;
    }

    public void setAttrValueList(List<String> attrValueList) {
        this.attrValueList = attrValueList;
    }

    /**
     * 将attrValue插入attrValue数组的尾部
     *
     * @param attrValue attrValue
     */
    public void append(String attrValue) {
        this.attrValueList.add(attrValue);
    }

    /**
     * 将一个该根据根据attrValueList拆分成n个对象并返回
     *
     * @return 生成的拆分对象数组
     */
    public List<MarkDetail> decomposeMarkDetailList() {
        List<MarkDetail> markDetailList = new ArrayList<>();
        for (String str : attrValueList) {
            markDetailList.add(new MarkDetail(this, str));
        }
        return markDetailList;
    }


    @Override
    public String toString() {
        return "MarkDetail{" +
                "detailId=" + detailId +
                ", markId=" + markId +
                ", attrNameId=" + attrNameId +
                ", attrName='" + attrName + '\'' +
                ", attrValueList=" + attrValueList +
                ", attrValue='" + attrValue + '\'' +
                '}';
    }
}
